package com.mingxun.project.http;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * class name：头部拦截器
 *
 * @author liuhongyuan.
 * @date 2017/12/19
 */

public class HttpHeaderInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        TokenHeaderHelper headerHelper = TokenHeaderHelper.get();
        String token = headerHelper.readToken();
        request = request.newBuilder().addHeader("token", token)
//                .addHeader("CLIENT","2")
//                .addHeader("APPVERSION", headerHelper.getVersion())
//                .addHeader("DeviceId", headerHelper.getDeviceId())
//                .addHeader("DeviceModel", headerHelper.getDeviceModel())
//                .addHeader("SysVersion", headerHelper.getSysVersion())
//                .addHeader("Channel", headerHelper.getChannel())
                .build();
        return chain.proceed(request);
    }
}
